package com.example.cinema.drawview;

import android.animation.TypeEvaluator;
import android.graphics.PointF;

public class Bazier implements TypeEvaluator<PointF> {

    private PointF pointF1;
    private PointF pointF2;

    public Bazier(PointF pointF0, PointF pointF1) {
        this.pointF1 = pointF0;
        this.pointF2 = pointF1;
    }

    @Override
    public PointF evaluate(float t, PointF s, PointF e) {
        PointF pointF = new PointF();
        pointF.x = s.x*(1-t)*(1-t)*(1-t)+3*pointF1.x*t*(1-t)*(1-t)+3*pointF2.x*t*t+e.x*t*t*t;
        pointF.y = s.y*(1-t)*(1-t)*(1-t)+3*pointF1.y*t*(1-t)*(1-t)+3*pointF2.y*t*t+e.y*t*t*t;
        return pointF;
    }
}
